﻿Chenxin.UI.CustomerList = Chenxin.extend(Chenxin.UI.PageCommon, {
    autoInitForm: false,
    actionUrl: 'service/CustomerList.ashx',
    createSearch: function() {
        return new Chenxin.UI.CustomerListSearch({
            scope: this,
            afterGetParamJson: function(data) {
                data.op = 'Search';
            }
        });
    },
    createGrid: function() {
        return new Chenxin.UI.Pagination({
            actionUrl: this.actionUrl,
            domId: 'page',
            renderTo: 'customer_table',
            data: { op: "Search" },
            render: function(data) {
                document.getElementById('customer_table').innerHTML = data;
            }
        });
    },
    info: function() {
        var _this = this;
        _this.renderInfo();
        _this.createList(_this.currentId);
    },
    renderInfo: function() {
        var m = this.keyuseinfo;
        var infoStr = '';
        infoStr += '<tr id="tr-house-info"><td height="81" colspan="11" class="gendan_box" >';
        infoStr += '<div class="gdtab"><div class="outborder">';
        infoStr += '<div class="infos intitss"><span class="rb" style="width:500px" ><b>跟单内容</b></span><span class="rbpsn" style="width:160px"><b>跟单人</b></span><span class="rbtim" style="width:80px"><b>跟盘时间</b></span></div>';
        infoStr += '<div id="info_table"></div>';
        infoStr += '</div><div id="info_page"></div></div></td</tr>';
        $('#' + this.currentId).after(infoStr);
    },
    createList: function(houseid) {
        var _this = this;
        if (!this.infoPage) {
            this.infoPage = new Chenxin.UI.Pagination({
                domId: 'info_page',
                pageSize: 3,
                actionUrl: 'service/CustomerList.ashx?op=gethousetracelist',
                data: { houseid: houseid },
                render: function(data) {
                    document.getElementById('info_table').innerHTML = data;
                }
            });
        } else {
            this.infoPage.recordCount = 0;
            this.infoPage.hasCount = false;
            this.infoPage.reload({ houseid: houseid });
        }
    },
    initEvent: function() {
        var _this = this;
        $('.tr_houselist').live('click', function() {
            var t = this.id.split(",")
            if (t.length == 2) {
                this.id = t[0];
                _this.currentName = t[1];
            }
            $('.tr_houselist,.selected_orgbgcolor').each(function() {
                $(this).removeClass('selected_orgbgcolor');
            });
            $(this).toggleClass('selected_orgbgcolor');
            if (!$('#tr-house-info').length) {
                _this.currentId = this.id;
                _this.info();

            } else {
                $('#tr-house-info').remove();
                if (_this.currentId != this.id) {
                    _this.currentId = this.id;
                    _this.info();
                }
            }
        });
    },
    initComponent: function() {
        Chenxin.UI.CustomerList.superclass.initComponent.call(this);
    }
}); 

/**
*查询面板
*/
Chenxin.UI.CustomerListSearch=Chenxin.extend(Chenxin.UI.SearchCommon,{
    id:'customer_search',
	initEvent:function(){
		var _this=this; 
        
		//查询按钮
		$('#btnSreachCustomer').click(function(){
		    _this.scope.reloadGrid();
		});
        
	},
    createComboList: function() {
    
        //五级联Combo
        var combl = new Chenxin.UI.StructComboList();
        var structs = combl.comboList;
        var customercode = new Chenxin.UI.Combo({
            containerId: '#CustomerCode',
            tbxWidth: 40,
            items: comboCommon.CustomerCode
        });
        var searchObj = new Chenxin.UI.Combo({
            containerId: '#SearchObj',
            tbxWidth: 40,
            items: comboCommon.SearchObj
        });
        structs.push(searchObj);
        structs.push(customercode);
		return structs;
    },
    initComponent: function() {
        Chenxin.UI.CustomerListSearch.superclass.initComponent.call(this);
    }
});

$(document).ready(function(){
    this.CustomerList=new Chenxin.UI.CustomerList();
});